
/**
  * @typedef Vector2Like
  * @property {number} x
  * @property {number} y
 */

/**
  * @typedef Vector3Like
  * @property {number} x
  * @property {number} y
  * @property {number} z
 */


/**
 * 线性插值
 * @param {number} n1
 * @param {number} n2
 * @param {number} alpha
 * @returns
 */
export const lerp = (n1, n2, alpha) => {

    return n1 + (n2 - n1) * alpha;

};

/**
 * 线性插值vec2
 * @param {Vector2Like} v1
 * @param {Vector2Like} v2
 * @param {number} alpha
 * @returns
 */
export const lerp2 = (v1, v2, alpha, dst = { x: 0, y: 0 }) => {

    dst.x = lerp(v1.x, v2.x, alpha);
    dst.y = lerp(v1.y, v2.y, alpha);

    return dst;

};
/**
 * 线性插值vec3
 * @param {Vector3Like} v1
 * @param {Vector3Like} v2
 * @param {number} alpha
 * @returns
 */
export const lerp3 = (v1, v2, alpha, dst = { x: 0, y: 0, z: 0 }) => {

    dst.x = lerp(v1.x, v2.x, alpha);
    dst.y = lerp(v1.y, v2.y, alpha);
    dst.z = lerp(v1.z, v2.z, alpha);

    return dst;

};
